package main.com.hushengjin.factory;

import main.com.hushengjin.model.Color;
import main.com.hushengjin.model.Shape;
import main.com.hushengjin.model.impl.shape.Circle;
import main.com.hushengjin.model.impl.shape.Rectangle;
import main.com.hushengjin.model.impl.shape.Square;

public class ShapeFactory extends AbstractFactory {
    @Override
    public Color getColor(String color) {
        return null;
    }

    @Override
    public Shape getShape(String shapeType) {
        if (shapeType == null || shapeType.trim().length() < 1)
            throw new IllegalArgumentException("传入参数类型不合法：" + shapeType);
        shapeType = shapeType.toUpperCase();
        Shape shape;
        switch (shapeType) {
            case "RECTANGLE":
                shape = new Rectangle();
                break;
            case "CIRCLE":
                shape = new Circle();
                break;
            case "SQUARE":
                shape = new Square();
                break;
            default:
                throw new IllegalArgumentException("传入参数类型不合法：" + shapeType);
        }
        return shape;
    }
}
